﻿/**********************************************************
 ●项目：Smartkernel
 ●公司：智能核心信息技术研发中心
 ●作者：曹艳白
 ●邮箱：caoyanbai@gmail.com
 ●创建：2008-08-10
 ●版本：1.0
**********************************************************/
using System;

namespace Smartkernel.Data
{
    /// <summary>
    /// 事务回滚的条件
    /// </summary>
    public class SmartRollbackCondition
    {
        private SmartRollbackConditionType rollbackConditionType;
        /// <summary>
        /// 命令回滚的条件类型
        /// </summary>
        public SmartRollbackConditionType RollbackConditionType
        {
            get
            {
                return this.rollbackConditionType;
            }
        }
        private Action rollbackAction;
        /// <summary>
        /// 命令回滚的自定义函数。触发回滚的方式是检查不符合条件时抛出异常。
        /// </summary>
        public Action RollbackAction
        {
            get
            {
                return this.rollbackAction;
            }
        }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="rollbackAction">命令回滚的条件</param>
        public SmartRollbackCondition(Action rollbackAction)
        {
            this.rollbackConditionType = SmartRollbackConditionType.Custom;
            this.rollbackAction = rollbackAction;
        }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="rollbackConditionType">回滚类型</param>
        public SmartRollbackCondition(SmartRollbackConditionType rollbackConditionType)
        {
            this.rollbackConditionType = rollbackConditionType;
        }
    }
}
